 package com.farm.resume.dao.impl;
 
 import com.farm.core.sql.query.DBRule;
 import com.farm.core.sql.query.DataQuery;
 import com.farm.core.sql.result.DataResult;
 import com.farm.core.sql.utils.HibernateSQLTools;
 import com.farm.resume.dao.ResumeintensionDaoInter;
 import com.farm.resume.domain.Resumeintension;
 import java.math.BigInteger;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Resource;
 import org.hibernate.Query;
 import org.hibernate.SQLQuery;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
 import org.springframework.stereotype.Repository;
 
 
 
 
 
 
 
 
 
 
 
 @Repository
 public class ResumeintensionDaoImpl
   extends HibernateSQLTools<Resumeintension>
   implements ResumeintensionDaoInter
 {
   @Resource(name="sessionFactory")
   private SessionFactory sessionFatory;
   
   public void deleteEntity(Resumeintension resumeintension)
   {
     Session session = this.sessionFatory.getCurrentSession();
     session.delete(resumeintension);
   }
   
   public int getAllListNum()
   {
     Session session = this.sessionFatory.getCurrentSession();
     SQLQuery sqlquery = session.createSQLQuery("select count(*) from farm_code_field");
     BigInteger num = (BigInteger)sqlquery.list().get(0);
     return num.intValue();
   }
   
   public Resumeintension getEntity(String resumeintensionid)
   {
     Session session = this.sessionFatory.getCurrentSession();
     return (Resumeintension)session.get(Resumeintension.class, resumeintensionid);
   }
   
   public Resumeintension insertEntity(Resumeintension resumeintension)
   {
     Session session = this.sessionFatory.getCurrentSession();
     session.save(resumeintension);
     return resumeintension;
   }
   
   public void editEntity(Resumeintension resumeintension)
   {
     Session session = this.sessionFatory.getCurrentSession();
     session.update(resumeintension);
   }
   
 
   public Session getSession()
   {
     return this.sessionFatory.getCurrentSession();
   }
   
   public DataResult runSqlQuery(DataQuery query)
   {
     try {
       return query.search(this.sessionFatory.getCurrentSession());
     } catch (Exception e) {}
     return null;
   }
   
 
   public void deleteEntitys(List<DBRule> rules)
   {
     deleteSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
   }
   
 
   public List<Resumeintension> selectEntitys(List<DBRule> rules)
   {
     return selectSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
   }
   
 
   public void updataEntitys(Map<String, Object> values, List<DBRule> rules)
   {
     updataSqlFromFunction(this.sessionFatory.getCurrentSession(), values, rules);
   }
   
 
   public int countEntitys(List<DBRule> rules)
   {
     return countSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
   }
   
   public SessionFactory getSessionFatory() {
     return this.sessionFatory;
   }
   
   public void setSessionFatory(SessionFactory sessionFatory) {
     this.sessionFatory = sessionFatory;
   }
   
   protected Class<?> getTypeClass() {
     return Resumeintension.class;
   }
   
   protected SessionFactory getSessionFactory()
   {
     return this.sessionFatory;
   }
   
   public Resumeintension getResumeintensionEntityByUser(String userid) {
     Session session = this.sessionFatory.getCurrentSession();
     Query query = session.createQuery("from Resumeintension where userid=?");
     query.setString(0, userid);
     
     List<Resumeintension> list = query.list();
     if (list.size() > 0) {
       return (Resumeintension)list.get(0);
     }
     return null;
   }
 }

